<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>注册</title>
	</head>
	<body>
		<form id="zhuce" method="post">
			<p>用户名:<input type="text" name="username" id="username" value="" /></p>
			<p>年龄:<input type="text" name="age" id="age" value="" /></p>
			<p>性别:<input type="text" name="sex" id="sex" value="" /></p>
			<p>邮箱:<input type="text" name="email" id="email" value="" /></p>
			<p>手机号:<input type="text" name="phone" id="phone" value="" /></p>
			<p>密码:<input type="password" name="password" id="password" value="" /></p>
			<input type="submit" value="注册"/>
		</form>
	</body>
	<script src="jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function (){
			$("#zhuce").on("submit",function(){
			$.ajax({
				type:"post",
				url:"01.ajax.php?type=zhuce",
				data:{
					username:$("#username").val(),
					password:$("#password").val(),
					age:$("#age").val(),
					sex:$("#sex").val(),
					phone:$("#phone").val(),
					email:$("#email").val()
				},
				success:function (data){
					if(data.error==0){
						alert("注册成功");
					}else{
						alert(data.message);
					}
				},
				error:function (){
				}
			});	
			return false;
		 });
		});
	</script>
</html>
